#include "../frame.h"
#include "../player.h"
#include "../match.h"
#include "../player_bonus.h"
#include "../pin_scheme.h"
#include "../turn.h"
#include "../frame_controller.h"


#define BOOST_TEST_MODULE Game test
#include <boost/test/unit_test.hpp>

/*
BOOST_AUTO_TEST_CASE( player_have_strike )
{
    Match match;
    auto john = std::shared_ptr<Player>(new Player("john"));
    auto olol = std::shared_ptr<Player>(new Player("olol"));
    match.attachPlayer(john);
    match.attachPlayer(olol);
    
    auto& controller = FrameController::getInstance();
    
    
    //controller.simulateTurn("1111111111");
    
    controller.simulateTurn("1111111111");
    controller.simulateTurn("1111111111");
    
    controller.simulateTurn("1111111111");
    
    
    BOOST_CHECK_EQUAL( john->getScores(), 30 );
    BOOST_CHECK_EQUAL( olol->getScores(), 10 );
}*/


BOOST_AUTO_TEST_CASE( all_players_have_strikes )
{       
    std::cout << "Run second autotest" << std::endl;
    Match match;
    auto john = std::shared_ptr<Player>(new Player("john"));
    auto olol = std::shared_ptr<Player>(new Player("olol"));
    match.attachPlayer(john);
    match.attachPlayer(olol);
    
    auto& controller = FrameController::getInstance();
    //PinScheme strike("1111111111");
    
    //std::cout << "0000 " << std::endl;
    
    
    try
    {
    
    const int allThrows = 24;
    for (int i = 0; i < allThrows; ++i)
    {
        //std::cout << "1111 " << std::endl;
        controller.simulateTurn("1111111111");
        
    }
    
    }catch(...)
    {
        std::cout << "some except!!!!!!!!" << std::endl;
    }
    
    BOOST_CHECK_EQUAL( john->getScores(), 300 );
    BOOST_CHECK_EQUAL( olol->getScores(), 300 );
    
    std::cout << "john scores " << john->getScores() << std::endl;

}

/*
BOOST_AUTO_TEST_CASE( game_simulation )
{        

    Match match;
    
    match.attachPlayer(std::unique_ptr<Player>(new Player("john")));
    match.attachPlayer(std::unique_ptr<Player>(new Player("olol")));
        
    Turn strike;
    strike.scheme = std::make_shared<PinScheme>("1111111111");

    Turn knocked3;
    knocked3.scheme = std::make_shared<PinScheme>("0111000000");
    
    Turn knocked5;
    knocked5.scheme = std::make_shared<PinScheme>("0011111000");
    
    Turn knocked7;
    knocked7.scheme = std::make_shared<PinScheme>("0011111101");    
    
    Turn miss;
    miss.scheme = std::make_shared<PinScheme>("0000000000");
    
    
    match.makeTurn(strike);
    
    match.makeTurn(knocked5);
    match.makeTurn(knocked3);
    
    match.makeTurn(knocked5);
    match.makeTurn(knocked5);
    
    match.makeTurn(knocked3);
    match.makeTurn(knocked3);
    
    match.makeTurn(knocked5);
    match.makeTurn(knocked5);    


    BOOST_CHECK( 5 == 5 );
    

}

*/


